package com.zwps.biz.domain.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zwps.biz.api.model.vo.structure.EquipmentGradeDetailVO;
import com.zwps.biz.api.model.vo.structure.ZEquipmentRecordVO;
import com.zwps.biz.api.model.vo.structure.ZIdentificationPlateVO;
import com.zwps.biz.dal.db.dao.ZEquipmentRecordDAO;
import com.zwps.biz.dal.db.dao.ZEquipmentRecordDetailDAO;
import com.zwps.biz.dal.db.object.ZEquipmentRecordDO;

import com.zwps.biz.dal.db.object.ZEquipmentRecordDetailDO;
import com.zwps.biz.domain.service.ZEquipmentRecordService;


import org.jsoup.select.Elements;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.WeakHashMap;
import java.util.stream.Collectors;

/**
 * @Author：yxm
 * @Package：com.zwps.biz.domain.service.impl
 * @Project：cqsk_manager
 * @name：ZEquipmentRecordServiceImpl
 * @Date：2025/4/18 下午6:11
 * @Filename：ZEquipmentRecordServiceImpl
 */
@DS("one")
@Service
public class ZEquipmentRecordServiceImpl extends ServiceImpl<ZEquipmentRecordDAO, ZEquipmentRecordDO> implements ZEquipmentRecordService {


    @Autowired
    private ZEquipmentRecordDetailDAO zEquipmentRecordDetailDAO;

    @Override
    public ZEquipmentRecordVO getZEquipmentRecord() {
        ZEquipmentRecordVO zEquipmentRecordVO = new ZEquipmentRecordVO();
        List<ZEquipmentRecordDetailDO> list = zEquipmentRecordDetailDAO.selectList(new LambdaQueryWrapper<ZEquipmentRecordDetailDO>()
                .eq(ZEquipmentRecordDetailDO::getParentId, 0));
        List<EquipmentGradeDetailVO> voList = list.stream()
                .map(item -> {
                    EquipmentGradeDetailVO vo = new EquipmentGradeDetailVO();
                    BeanUtils.copyProperties(item, vo);
                    return vo;
                })
                .collect(Collectors.toList());
        zEquipmentRecordVO.setProjectGradeDetailList(voList);
        zEquipmentRecordVO.setEquipmentGradeDetailList(zEquipmentRecordDetailDAO.getEquipmentGradeDetailList());
        zEquipmentRecordVO.setEquipmentRate(zEquipmentRecordDetailDAO.getEqipmentRate());
        return zEquipmentRecordVO;

    }

    @Override
    public List<ZIdentificationPlateVO> getIdentification(Integer type) {
        if (type==1){
       return zEquipmentRecordDetailDAO.getIdentification( type);
        }else if (type==2){
            return zEquipmentRecordDetailDAO.getElectronicBoundary( type);
        }
     return new ArrayList<>();
    }


}

